package com.denlaku.longan.repository;

import com.denlaku.longan.anno.VarOp;
import com.denlaku.longan.dao.LinkageAimDao;
import com.denlaku.longan.vo.LinkageAim;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author tianx
 */
@Repository
public class LinkageAimRepository {
    @Autowired
    private LinkageAimDao linkageAimDao;

    /**
     * 批量增加联动目标信息
     * @param linkageAim 联动目标信息
     */
    @VarOp
    public void batchAdd(List<LinkageAim> linkageAim) {
        linkageAimDao.batchAdd(linkageAim);
    }

    /**
     * 删除联动信息
     *
     * @param tenantId 租户id
     * @param componentIds 组件id
     */
    public void delete(Long tenantId, List<Long> componentIds) {
        if (CollectionUtils.isNotEmpty(componentIds)) {
            linkageAimDao.delete(tenantId, componentIds);
        }
    }

    /**
     * 查询联动目标信息
     *
     * @param tenantId 租户ID
     * @param componentIds 组件ID
     * @return 联动目标
     */
    public List<LinkageAim> list(Long tenantId, List<Long> componentIds) {
        return linkageAimDao.list(tenantId, componentIds);
    }

}
